
import 'package:dingtalk/core/values/values.dart';
import 'package:flutter/material.dart';

class THCommonListItem extends StatelessWidget {
  final Widget leading;

  final Widget title;

  final Widget trailing;

  final bool showDivider;

  final bool showArrow;

  final Function onItemPress;

  THCommonListItem(
      {this.leading,
      this.title,
      this.trailing,
      this.showDivider = true,
      this.showArrow = false,
      this.onItemPress});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      child: Container(
        decoration: BoxDecoration(color: Colors.white),
        child: Row(
          children: <Widget>[
            leading != null
                ? Container(
                    constraints:
                        BoxConstraints(minHeight: kSize100, minWidth: kSize100),
                    alignment: Alignment.center,
                    child: leading,
                  )
                : SizedBox(),
            Expanded(
              child: Padding(
                padding: EdgeInsets.only(left: kSize24),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Container(
                      constraints: BoxConstraints(minHeight: kSize100),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: <Widget>[
                          title ?? SizedBox(),
                          Row(
                            children: <Widget>[
                              trailing ?? SizedBox(),
                              showArrow
                                  ? Padding(
                                      padding: EdgeInsets.only(
                                          left: kSize8, right: kSize16),
                                      child: Icon(
                                        Icons.arrow_forward_ios,
                                        size: kSize28,
                                        color: kColor99,
                                      ),
                                    )
                                  : SizedBox(),
                            ],
                          )
                        ],
                      ),
                    ),
                    showDivider
                        ? Divider(height: kSize2, color: kColor99)
                        : SizedBox()
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
      onTap: onItemPress,
    );
  }
}
